{% extends "dynamic/base.html" %}

{% load i18n adminmedia %}

{% block stylesheet %}{% admin_media_prefix %}css/dashboard.css{% endblock %}
{% block bodyclass %}change-list{% endblock %}
{% block coltype %}flex{% endblock %}

{% block extrahead %}{{ block.super }}

<style>
    #content-main {
        width: 100%;
    }
</style>
<script>
    function selectAll() {
        var top_checked = $('input[type=checkbox][name=item]:first').attr('checked');
        $('input[type=checkbox][name=item]').attr('checked',top_checked ? '' : 'checked');
    }

    function formOnSubmit() {
        if (!$('input[type=checkbox][name=item][checked]').length) {
            alert('{% trans "You must check the files you want do this action!" %}');
            return false;
        }
    }

    function uploadFiles() {
        window.location = 'upload/?f={{ current_path }}';
    }
</script>
{% endblock extrahead %}

{% block content %}
<div id="content-main">
    <div class="module">
        <form method="post" onsubmit="return formOnSubmit()">
            <input type="hidden" name="f" value="{{ current_path|safe }}"/>

    <table width="100%">
        <caption>{% trans "PROJECT ROOT" %}{{ current_path }} {% if current_path %}<a href="?f={{ parent_path }}">({% trans "parent" %})</a>{% endif %}</caption>
        <thead>
            <tr>
                <th>&nbsp;</th>
                <th>{% trans "Filename" %}</th>
                <th>{% trans "Type" %}</th>
                <th>{% trans "Size" %}</th>
            </tr>
        </thead>

        {% for file in files_list %}
        <tr>
            <td width="1" nowrap="nowrap">
                <input name="item" type="checkbox" value="{{ file.filename }}"/>
            </td>
            <td>
                <a href="{{ file.view_link }}">{{ file.filename }}</a>
                <a href="{{ file.edit_link }}" title="{% trans "Edit" %}"><img src="{% admin_media_prefix %}img/admin/icon_changelink.gif" alt="{% trans "Edit" %}"/></a>
            </td>
            <td>{{ file.mimetype }}</td>
            <td>{{ file.size|filesizeformat }}</td>
        </tr>
        {% endfor %}
    </table>

            <div style="padding: 5px">
                <input type="button" value="{% trans "Select all" %}" onclick="selectAll()"/>
                <input type="submit" name="delete" value="{% trans "Delete selected" %}"/>
                <input type="submit" name="rename" value="{% trans "Rename selected" %}"/>
                <input type="submit" name="move" value="{% trans "Move selected" %}"/>
                <input type="button" value="{% trans "Upload files" %}" onclick="uploadFiles()"/>
            </div>
        </form>
    </div>
</div>
{% endblock content %}

